<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn"  uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx"><%=request.getContextPath()%></c:set>
<!DOCTYPE html>
<!-- saved from url=(0037)http://www.pinpaitg.net/hindex-1.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> 
<meta content="yes" name="apple-mobile-web-app-capable"> 
<meta content="yes" name="apple-touch-fullscreen">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="320" name="MobileOptimized">
<meta content="telephone=no" name="format-detection"> 
<link rel="apple-touch-icon" href="">
<title></title> 
<link rel="stylesheet" href="${ctx}/styles/mobile/qdwap.css">
<link rel="stylesheet" href="${ctx}/styles/mobile/swipe.css">
<style>

	#send_mobile_code_id.disabled{
		  pointer-events: none;
		  cursor: not-allowed;
		  opacity: 0.65;
		  filter: alpha(opacity=65);
		  -webkit-box-shadow: none;
		          box-shadow: none;
	}
	
	#tel.disabled,#tel[disabled]{
		cursor: not-allowed;
  		background-color: #eeeeee;
	}
	
	.thumbnail {
		  display: inline-block;
		  display: block;
		  height: auto;
		  max-width: 100%;
		  padding: 4px;
		  margin-bottom: 20px;
		  line-height: 1.428571429;
		  background-color: #ffffff;
		  border-radius: 4px;
		  -webkit-transition: all 0.2s ease-in-out;
		          transition: all 0.2s ease-in-out;
		}
		
		.thumbnail > img {
		  display: block;
		  height: auto;
		  max-width: 100%;
		  margin-right: auto;
		  margin-left: auto;
		}
		
		a.thumbnail:hover,
		a.thumbnail:focus,
		a.thumbnail.active {
		  border-color: #428bca;
		}
		
		.thumbnail .caption {
		  padding: 9px;
		  color: #333333;
		}
		
		.thumbnail{
			position: relative;	
		}
		
		.weui-mask {
    position: fixed;
    z-index: 1000;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}
.weui-dialog {
    position: fixed;
    z-index: 5000;
    width: 80%;
    max-width: 300px;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background-color: #FFFFFF;
    text-align: center;
    border-radius: 3px;
    overflow: hidden;
}
.weui-dialog__bd:first-child {
    padding: 2.7em 20px 1.7em;
    color: #353535;
}
.weui-dialog__bd {
    padding: 0 1.6em 0.8em;
    min-height: 40px;
    font-size: 15px;
    line-height: 1.3;
    word-wrap: break-word;
    word-break: break-all;
    color: #999999;
    border-bottom: 1px solid #ccc;
}
.weui-dialog__ft {
    position: relative;
    line-height: 48px;
    font-size: 18px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
}
.weui-dialog__btn_primary {
    color: #0BB20C;
}
.weui-dialog__btn {
    display: block;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    color: #000;
    text-decoration: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    position: relative;
}
.weui-btn_primary {
    background-color: #f30;
}
.weui-btn {
    position: relative;
    display: block;
    margin-left: auto;
    margin-right: auto;
    padding-left: 14px;
    padding-right: 14px;
    box-sizing: border-box;
    font-size: 18px;
    text-align: center;
    text-decoration: none;
    color: #FFFFFF;
    line-height: 2.55555556;
    border-radius: 5px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    overflow: hidden;
}
</style>
<script src="${ctx}/js/mobile/jquery.js?t=00134234"></script>
<script src="${ctx }/js/mobile/time.lesser.js?t=23423"></script>
<script src="${ctx}/js/scrolllLoading/jquery.scrollLoading.min.js"></script> 


<script>
  addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); 
  function hideURLbar(){ 
    window.scrollTo(0,1); 
  } 
  
$ = jQuery;
 

function CheckSubmit()
{	  
	if(document.form2.name.value=="")
	{
   		document.form2.name.focus();
   		alert("请输入您的中文姓名！");
   		return false;
	}

    if (document.form2.name.value != ""){ 	
	var namereg=/^[\u4e00-\u9fa5]{2,4}$/;
    var name=document.form2.name.value;
    if (!namereg.test(name)){
     alert("您的姓名输入错误！姓名只允许2至4个汉字！");
     document.form2.name.focus();
     return false;
    }
   }
	
	if(document.form2.mobile.value=="")
	{
   		document.form2.mobile.focus();
   		alert("请填写您的手机号码！");
   		return false;
	}
	
    if (document.form2.mobile.value != ""){   
    var mobile=document.form2.mobile.value; 
	var reg=/^0?(13[0-9]|15[012356789]|18[012356789]|14[57])[0-9]{8}$/;
    var my = false;   
    if (reg.test(mobile))my=true;   
    if (!my){   
    document.form2.mobile.value='';   
    alert('您输入的手机号码有误！');   
    document.form2.mobile.focus();   
    return false;   
    }
	}
	
	if(document.form2.province.value=="")
	{
   		document.form2.province.focus();
   		alert("请选择您所在省份！");
   		return false;
	}	
	
	if(document.form2.city.value=="")
	{
   		document.form2.city.focus();
   		alert("请选择您所在城市！");
   		return false;
	}		
	
	if(document.form2.area.value=="")
	{
   		document.form2.area.focus();
   		alert("请输入您的收货地址！");
   		return false;
	}

	if(document.form2.num.value=="")
	{
   		document.form2.num.focus();
   		alert("请输入您要购买的商品数量！");
   		return false;
	}
	
	if(document.form2.color.value=="")
	{
   		document.form2.color.focus();
   		alert("请选择您购买的颜色！");
   		return false;
	}	
	
	if(document.form2.size.value=="")
	{
   		document.form2.color.focus();
   		alert("请选择您购买的尺码！");
   		return false;
	}	
	
	return true;
}
</script>
      
</head>
<body> 


<div id="page">

   <header>
    <h1 id="title_id"></h1>
   </header>
  <div class="banner">
  <img src="./" id="title_img_id">
  </div>
  
  <section class="buy shop-box">
     <div class="row1">
       <strong id="nowprice"></strong>
       <ol>
        <li><p>原价</p><span id="oldprice"></span></li>
        <li><p>折扣</p><span id="discount_id">1.0</span> </li>
        <li><p>节省</p><span id="jieshen_id"></span> </li>
       </ol>
     </div>
     <div class="row2">
      <strong id="lastsale_id">21221人已购买</strong>
      <div class="djs">
       <div class="time-count">
            <div id="remainTime_1" class="jltimer"><span>回馈促销，仅此一天</span></div>
            <script language="javascript">
                addTimeLesser(1, -2485008);
            </script>
        </div>
       </div>             
     </div>
     <article class="des"></article>
     <a class="btn" href="#buy">立即购买</a>
    </section>
    <article class="showcontent">    
 
<h2>
	购买流程</h2>
              <img src="https://pic.kuaizhan.com/g3/7f/63/165a-7ddb-483f-99d5-df353524aa4f68" alt="购买流程">
              <img src="https://pic.kuaizhan.com/g3/2a/dd/6ed7-ba48-439b-b444-25f7563df60006" alt="购买流程">  
          
<h2>产品简介</h2>  
<p id="picList_id">

</p>

<!-- <h2> -->
<!-- 	证书保障</h2> -->
<!--           <img src="./shop_files/2a82ebf820140327091115.jpg" alt="证书保障1"> -->

<!-- <h2> -->
<!-- 	保养建议</h2> -->
<!--           <img src="./shop_files/67be352120140327091137.jpg" alt="保养建议1">	 -->
 
<!-- <h2> -->
<!-- 	款式展示</h2> -->
<!-- &nbsp;          <img src="./shop_files/2f2dfc2f20140327091154.jpg" alt="款式展示1">		      -->
    </article>
  
  
     <article id="buy">
     <h2>订单信息</h2>
      <form method="post" action="" name="form2" id="qd-order" style="padding:10px 0;">		
    				 <input type="hidden" name="goodsId" value="${id }" id="goodsId"/>
    				 <input type="hidden" name="orderToken" value="${orderToken}" id="goodsId"/>
    				 <input type="hidden" name="host" id="host_id"/>
	<div class="fieldcontain">
	         <label for="name">收货人姓名<font color="red">*</font></label>
	         <input type="text" name="name" id="name" value="" pattern="^[\u4e00-\u9fa5]{2,4}$" placeholder="请输入您的姓名或称呼" required="">
			</div>
					   
			<div class="fieldcontain">
	         <label for="tel">收货人电话<font color="red">*</font></label>
	         <input type="tel" name="mobile" id="tel" value="" pattern="^0?(13[0-9]|15[012356789]|18[012356789]|14[57])[0-9]{8}$" placeholder="请输入您的手机号码" required="" >
			</div>		   	
			 		   	

			<div class="fieldcontain">
	         <label for="province">省市<font color="red">*</font></label>
                <select  name="province" id="province">
                                    
				</select>  
                <span id="selparent_id">
                <select id="city" name="city"><option value="请选择城市名">请选择城市名</option></select>  
                </span>   
			</div>	

            <div class="fieldcontain">
	         <label for="county">区镇<font color="red">*</font></label>
             <span id="selregion_id">
             <select id="county" class="select" name="area">
              <option value="0" selected="">请选择区镇名</option>
              </select>           
              </span>
			</div>
			<div class="fieldcontain">
	         <label for="address">收货地址<font color="red">*</font></label>
	         <input type="text" name="street" id="address" value="" placeholder="请填写详细地址,方便快递人员送货上门">
			</div>	
            
			
 			<div class="fieldcontain">
	         <label for="number-pattern">商品数量<font color="red">*</font></label>
	         <input type="number" name="num" maxlength="2"  pattern="[0-9]*" id="number-pattern" value="1" placeholder="">
			</div>
			
			
  			<div class="fieldcontain sel">
            
            	<label for="title" id="colorDesc_id">颜色选择<font color="red">*</font></label>
                <select name="color" id="color_ids">
                     
                </select>
                
                <label for="title" id="sizeDesc_id" style="display: none;">尺码选择<font color="red">*</font></label>
                <select name="size" id="size_ids" style="display: none;">
                     
                </select>
                
			</div>          
            
            
			<div class="fieldcontain">
			<label for="textarea-a">您的留言(选填)</label>
			<textarea name="remark" id="textarea-a" rows="6" style="height:100px;" placeholder="可以告诉卖家您对商品的特殊要求，如：颜色、数量等"></textarea> 
			</div>
						
    		<input name="action" id="action" type="hidden" value="add">
        	<div class="fieldcontain"><button type="button" id="add_order_btn">填写好了 提交订单</button>
        	<button type="button" id="weixin_btn"></button>	</div>
	     </form>	
		 
         
         
         
      </article>   

   <footer>
	<p><img src="${ctx }/images/renz.png"></p>

   </footer>
		
</div><!-- /page -->


<nav>
<ul class="Transverse">
     <li style="width:33.33%;"><a href="${ctx }/?gzid=${param.gzid}"><strong>首页</strong></a></li> 
	 <li style="width:33.33%;"><a href="#buy"><strong>立即购买</strong></a></li>  
  	 <li id="qq_a" style="width:33.33%;"><a href="#" data-qq="3031229445"><strong>客服咨询</strong></a></li>
  </ul>
</nav> 

<div style="display: none;">
 <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?5daa65529d285385308e99c1eaa6eebf";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>

<div class="js_dialog" id="iosDialog2" style="display:none;">
            <div class="weui-mask"></div>
            <div class="weui-dialog">
                <div class="weui-dialog__bd">
                	<div style="position:absolute;left:5px;top:5px;"><img src="${ctx }/images/nake_logo.jpg" style="width:50px;"/><span id="title_id"></span></div>
                	<div style="margin-top:15px;"><div class="weui-btn weui-btn_primary" id="qq_id"></div></div>
                	<div style="margin-top:15px;"><div class="weui-btn weui-btn_primary" id="weixin_id"></div></div>
                	<div style="margin-top:15px;">长按复制号码</div>
                	<div></div>
                </div>
                <div class="weui-dialog__ft">
                    <a href="javascript:;" id="iknow" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
                </div>
            </div>
        </div>

<div class="js_dialog" id="order_success_id" style="display:none;">
            <div class="weui-mask"></div>
            <div class="weui-dialog">
                <div class="weui-dialog__bd">
                	<div style="position:absolute;left:5px;top:5px;"><img src="${ctx }/images/nake_logo.jpg" style="width:50px;"/><span></span></div>
                	<div style="margin-top:15px;">尊敬的用户，您已下单成功，我们会尽快为您安排发货，为了让用户更省心、放心、我们订单统一采用货到付款方式，到时您亲自验货认为鞋子没问题后再付款给快递人员即可！</div>
                	<div></div>
                </div>
                <div class="weui-dialog__ft">
                    <a href="${ctx }/?gzid=${param.gzid}" class="weui-dialog__btn weui-dialog__btn_primary">返回首页</a>
                </div>
            </div>
        </div>

<script>

	$(function(){
		
		$("#qq_a").click(function(){
			$('#iosDialog2').show();
			return false;
		});
		
		$('#iknow').click(function(){
			$('#iosDialog2').hide();
			return false;
		});
		//设置商品详细信息
		  jQuery.ajax({
				type : 'Get',
				contentType : 'application/json',
				url : '${ctx}/goods/get.do',
				async:false,
				data : {
					id : "${id}",
				},
				dataType : 'json',
				success : function(data) {
					if(data.result){
						var obj = data.obj;
						
						//设置商品基本信息
						var goods = obj.goods;
						if(goods.picName.indexOf('http') != -1) {
							$("#title_img_id").attr("src",goods.picName).attr("alt",goods.title);
						} else {
							$("#title_img_id").attr("src","${ctx }/upload/download.do?fileName="+goods.picName).attr("alt",goods.title);
						}
						//$(".shop-box .shopinfo").html(goods.title);
						$(".shop-box #lastsale_id").html(goods.buyNum+"人已购买");
						$(".shop-box #nowprice").html("￥"+goods.nowPrice);
						$(".shop-box #discount_id").html(goods.discount.toFixed(1));
						$(".shop-box #oldprice").html("￥"+goods.price);
						$(".shop-box #jieshen_id").html("￥"+(goods.price-goods.nowPrice));
						//设置商品详情信息
						$("#goods_content").html(goods.content);
						
						var picList = obj.picList;
						
						for(var i = 0 ;i<picList.length;i++){
							//TODO设置图片
							if(picList[i].name.indexOf('http') != -1) {
								var img = '<div class="thumbnail" align="center" style="min-height:20px;"><img alt="" class="lazyImg" src="${ctx}/images/d_loading.gif"  data-url="'+picList[i].name+'"></div>';
							}else{
								var img = '<div class="thumbnail" align="center" style="min-height:20px;"><img alt="" class="lazyImg" src="${ctx}/images/d_loading.gif"  data-url="${ctx }/upload/download.do?fileName='+picList[i].name+'"></div>';
							}
							
							$("#picList_id").append(img); 
						}
						
						$(".lazyImg").scrollLoading();
						//设置颜色信息
						var colorList = obj.colorList;
						var colorListObj = {};
						if(colorList){
							
							var colorHtml = '<option value="">请选择</option>';
							for(var j = 0;j<colorList.length;j++){
								var color = colorList[j];
								var id = color.id;
								colorListObj[id] = color;
								colorHtml  = colorHtml +'<option data-id="'+color.id+'" value="'+color.color+'">'+color.color+'</option>';
								$("#color_ids").html(colorHtml);	
							}
							$("#color_ids").data("obj",colorListObj).data("list",colorList);
							
							
						}
						
						//设置尺码信息
						var sizeList = obj.sizeList;
						var sizeListObj = {};
						if(sizeList && sizeList.length>0){
							$("#sizeDesc_id").show();
							
							var sizeHtml = '<option value="">请选择</option>';
							for(var k = 0 ;k<sizeList.length;k++){
								var size = sizeList[k];
								var id= size.id;
								sizeListObj[id] = size;
								sizeHtml = sizeHtml +'<option data-id="'+size.id+'" value="'+size.size+'">'+size.size+'</option>';
								$("#size_ids").html(sizeHtml);
							}
							$("#size_ids").show().data("obj",sizeListObj).data("list",sizeList);
						}
					}
					
				}
		  });
		
		//公告管理
			jQuery.ajax( {
					type : 'Get',
					url : '${ctx}/webinfo/getWebInfo.do',
					dataType : 'json',
					contentType : 'application/json',
					async:false,
					success : function(data) {
						if(data.result){
							var obj = data.obj;
							$('title').html(obj.name);
							$('#title_id').html(obj.name);
							$('#qq_id').html('QQ：'+obj.qq);
							$('#weixin_btn').html('下单后联系微信：'+obj.weixin1+'领取单号');
							$('#weixin_id').html('微信：'+obj.weixin);
						}
					}
			});
		  
		  //获取所有省份
		  jQuery.ajax({
				type : 'Get',
				contentType : 'application/json',
				url : '${ctx}/address/getAll.do',
				dataType : 'json', 
				async:false,
				success : function(data) {
					if (data.result) {
						var provinceList = data.obj;
						var proHtml = '<option value="">请选择省份名</option>';
						for(var i = 0;i<provinceList.length;i++){
							var item = provinceList[i];
							proHtml = proHtml +'<option value="'+item.code+"|"+item.name+'">'+item.name+'</option>';
						}
						$("#province").html(proHtml);
					} else {
						
					}
				},
				error : function(data) {
					 
				}
			});
			
			$("#province").change(function(){
				var provincecode = $(this).val().split("|")[0];
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : '${ctx}/address/getByProvincecode.do',
					dataType : 'json',
					async:false,
					data:{
						provincecode:provincecode
					},
					success : function(data) {
						if (data.result) {
							var cityList = data.obj;
							var proHtml = '<option value="">请选择城市名</option>';
							for(var i = 0;i<cityList.length;i++){
								var item = cityList[i];
								proHtml = proHtml +'<option value="'+item.code+"|"+item.name+'">'+item.name+'</option>';
							}
							$("#city").html(proHtml);
						} else {
							
						}
					},
					error : function(data) {
						 
					}
				});
			});
			
			$("#city").change(function(){
				var citycode = $(this).val().split("|")[0];
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : '${ctx}/address/getByCitycode.do',
					dataType : 'json',
					data:{
						citycode:citycode
					},
					async:false,
					success : function(data) {
						if (data.result) {
							var cityList = data.obj;
							var proHtml = '<option value="">请选择区镇名</option>';
							for(var i = 0;i<cityList.length;i++){
								var item = cityList[i];
								proHtml = proHtml +'<option value="'+item.code+"|"+item.name+'">'+item.name+'</option>';
							}
							$("#county").html(proHtml);
						} else {
							
						}
					},
					error : function(data) {
						 
					}
				});
				
			});
			
			//提交订单
			$("#add_order_btn").click(function(){
				if(!CheckSubmit()){
					return false;
				}
				
				var gzid = '${param.gzid}';
				if(gzid){
					$("#host_id").val(window.location.host+","+gzid+","); 
				}else{
					$("#host_id").val(window.location.host);
				}
				
				
				var postData = $("#qd-order").serialize();
				$.ajax({
					type : "POST",
					url : "../order/addDpShop.do", 
					data : postData,
					dataType : "json",
					success : function(data) {
						if (data.result) {
							$('#order_success_id').show();
						} else {
							alert(data.errorMsg);
						}
					},
					error : function(data) {
						alert("系统繁忙，请您稍后再试！");
					}
				});	
			});
			
			//联动size
			$("#color_ids").change(function(){
				var sizeList = $("#size_ids").data("list");
				var sizeListObj = $("#size_ids").data("obj");
				var sizeHtml = '<option value="">请选择</option>';
				var val = $(this).val();
				if(!val){
					for(var k = 0 ;k<sizeList.length;k++){
						var size = sizeList[k];
						sizeHtml = sizeHtml +'<option data-id="'+size.id+'" value="'+size.size+'">'+size.size+'</option>';
					}
					$("#size_ids").html(sizeHtml);
					return false;
				}
				var colorId = $(this).find("option[value='"+val+"']").data("id");
				jQuery.ajax({
					type : 'Get',
					contentType : 'application/json',
					url : '../goods/getColorSizeItemListByColorId.do',
					data : {
						colorId:colorId
					},
					dataType : 'json',
					async:false,
					success : function(data) {
						if(data.result){
							var colorSizeItemList = data.obj;
							//var sizeIds = [];
							if(colorSizeItemList){
								for(var i = 0;i<colorSizeItemList.length;i++){
									var sizeId = colorSizeItemList[i].sizeId;
									var size = sizeListObj[sizeId];
									sizeHtml = sizeHtml +'<option data-id="'+size.id+'" value="'+size.size+'">'+size.size+'</option>';
								}
								$("#size_ids").html(sizeHtml);
							}
						}
					}
				});	
			});
			
			 
			
			
// 			//联动color
// 			$("#size_ids").change(function(){
// 				var val = $(this).val();
// 				var colorList = $("#color_ids").data("list");
// 				var colorListObj = $("#color_ids").data("obj");
// 				var colorHtml = '<option value="">请选择</option>';
// 				//如果回到请选择，放开所有颜色
// 				if(!val){
// 					for(var j = 0;j<colorList.length;j++){
// 						var color = colorList[j];
// 						var id = color.id;
// 						colorListObj[id] = color;
// 						colorHtml  = colorHtml +'<option data-id="'+color.id+'" value="'+color.color+'">'+color.color+'</option>';
							
// 					}
// 					$("#color_ids").html(colorHtml);
// 					return;
// 				}
// 				var sizeId = $(this).find("option[value='"+val+"']").data("id");
// 				jQuery.ajax({
// 					type : 'Get',
// 					contentType : 'application/json',
// 					url : '../goods/getColorSizeItemListBySizeId.do',
// 					data : {
// 						sizeId:sizeId
// 					},
// 					dataType : 'json',
// 					async:false,
// 					success : function(data) {
// 						if(data.result){
// 							var colorSizeItemList = data.obj;
// 							//var sizeIds = [];
// 							if(colorSizeItemList){
								
// 								for(var i = 0;i<colorSizeItemList.length;i++){
// 									var colorId = colorSizeItemList[i].colorId;
// 									var color = colorListObj[colorId];
// 									colorHtml  = colorHtml +'<option data-id="'+color.id+'" value="'+color.color+'">'+color.color+'</option>';
// 								}
// 								$("#color_ids").html(colorHtml);
// 							}
// 						}
// 					}
// 				});	
// 			});
			
			
	});
</script>
</body></html>